<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>国内配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
</head>
<body>
<div style="width:80%;margin:15px auto;overflow:auto;" id="aaa">
    <form class="layui-form" action="">
        <div style="text-align: center">
        <div style="font-size: large;margin: 3% 0;">国内IP配置</div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <textarea id="content" name="content" class="layui-textarea" style="height: 500px" lay-verify="content" ></textarea>
            </div>
        </div>
        </div>

        <div class="layui-form-item" style="margin-top: 20px">
            <div class="" style="text-align: center">
                <button class="layui-btn" id="addGuonei_peizhi" lay-submit lay-filter="addGuonei_peizhi">保存</button>
            </div>
        </div>
    </form>
</div>
<script src="/js/layui/layui.js"></script>
<script src="/js/layui/layui.all.js"></script>
<script src="/admin/js/token.js"></script>

<script>

    layui.use(['form' , 'jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        window.onload = function(){
            //读取国内配置文件
            $.ajax({
                url: "/peizhi/duqu_wenjian"
                , type: "POST"
                , data: {"type":0}
                , success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg)
                    } else if(data.code==0) {
                        $("#content").val(data.data);
                    }else{
                        layer.msg('拒绝访问');
                    }
                }
                ,error:function () {
                    console.log("ajax error");
                }
            })
        }
        //添加操作
        form.on('submit(addGuonei_peizhi)',function(data){
            $.ajax({
                url: "/peizhi/xie_wenjian"
                , type: "POST"
                , data: {"type":0,"context":$("#content").val()}
                , success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg)
                    } else if(data.code==0) {
                        layer.msg(data.msg);
                    }else{
                        layer.msg('拒绝访问');
                    }
                }
                ,error:function () {
                    console.log("ajax error");
                }
            })
            return false;
        });
    });
</script>
</body>
</html>